<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        #box1{
            width: 200px;
            height: 200px;
            background-color: yellowgreen;
        }
        
        #s1{
            background-color: yellow;
        }
    </style>   
    <script type="text/javascript">
	
        window.onload = function(){
            
            //为s1绑定一个单击响应函数
            var s1 = document.getElementById("s1");
            s1.onclick=function(){
                alert("我是span单击响应函数");
            }
            
            //为box1绑定一个单击响应函数
            var box1 = document.getElementById("box1");
            box1.onclick=function(){
                alert("我是box1单击响应函数");
            }
            
            //body绑定一个单击响应函数
            document.body.onclick = function(){
                alert("我是body单击响应函数")
            }
        }
    </script>    
</head>
<body>
    <body>
        <div id="box1">
            我是box1
            <span id="s1">我是span</span>
        </div>
    </body>
    
</body>
</html>